<template>
    <van-nav-bar title="分类" left-text="返回" left-arrow @click-left="onClickLeft" />
    <van-skeleton title :row="3" v-show="status" />
    <van-row>
        <van-col span="8">
            <van-sidebar v-model="active">
                <van-sidebar-item v-for="item in claData" :title="item.cat_name" />
            </van-sidebar>
        </van-col>
        <van-col span="16">
            <van-pull-refresh v-model="loading" @refresh="onRefresh">
                <div v-for="item in claData[active]?.children">
                    <h3>{{ item.cat_name }}</h3>
                    <router-link :to="'/goods/' + item.cat_name">
                        <van-grid :column-num="4">
                            <van-grid-item v-for="items in item.children"  :icon="items.cat_icon"
                                :text="items.cat_name" />
                        </van-grid>
                    </router-link>
                </div>
            </van-pull-refresh>
        </van-col>
    </van-row>
</template>

<script setup>
import { claApi } from '@/api/api';

import { ref } from 'vue';
let claData = ref([])
claApi().then(res => {
    console.log(res);
    claData.value = res.data.message

})
import { showToast } from 'vant';
    const loading = ref(false);
const onRefresh = () => {
    setTimeout(() => {
        showToast('刷新成功');
        loading.value = false;
        count.value++;
    }, 1000);
};
const status = ref(true)
setTimeout(() => {
    status.value = false
}, 2000);
let active = ref(1)
</script>

<style lang="scss" scoped></style>